/**
 * 
 */
package wpmp.security.mgr.base;

/**
 * @author Wayne.Wang<5waynewang@gmail.com>
 * @since 3:45:13 PM Jan 4, 2013
 */
public class SqlOrder {

	private boolean ascending;

	private String propertyName;

	public String toString() {
		return propertyName + ' ' + (ascending ? "asc" : "desc");
	}

	/**
	 * Constructor for Order.
	 */
	protected SqlOrder(String propertyName, boolean ascending) {
		this.propertyName = propertyName;
		this.ascending = ascending;
	}

	/**
	 * Ascending order
	 * 
	 * @param propertyName
	 * @return Order
	 */
	public static SqlOrder asc(String propertyName) {
		return new SqlOrder(propertyName, true);
	}

	/**
	 * Descending order
	 * 
	 * @param propertyName
	 * @return Order
	 */
	public static SqlOrder desc(String propertyName) {
		return new SqlOrder(propertyName, false);
	}

	public boolean isAscending() {
		return ascending;
	}

	public String getPropertyName() {
		return propertyName;
	}
}
